<!DOCTYPE html>
<html>
	<head>
		<title>Tyvo Ranger</title>
		<link rel="stylesheet" type="text/css" title="theme1" href="css/theme1.css"/>
		<script type="text/javascript" src="ajax_comment.js"></script>
		<script type="text/javascript" src="ajax_like.js"></script>
	</head>
<body>
	<?php
			include 'views/header_view.php';
			$_id = $post['ID_post'];
	?>
	<div class="primaryContent">
		<div id="container" class="container">
			<div id="content-view">
				<!-- content -->
				<h2 id="titlein"><?php echo $post['judul']; ?></h2>
					
				<?php if ($post['wujud']==2) { ?>
					<img id="img_in" height="400" width="600" src="<?php echo $post['link'] ?>" alt="<?php echo $post['judul'] ?>"/>
				<?php } else if ($post['wujud']==0) { ?>
					<span class="link">
						<span class="url"><?php echo $post['link']?></span><br/>
						<span class="desc"><?php echo $post['deskripsi'] ?></span>
					</span>
				<?php } else if ($post['wujud']==1) {
					$url = $post['link'];
					preg_match('/[\\?\\&]v=([^\\?\\&]+)/',$url,$matches);
					$id = $matches[1];
					$width = '600';
					$height = '400';
					echo '<object id="video_in" width="' . $width . '" height="' . $height . '"><param name="movie" value="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>';
			 } ?>
				<div id="info-content">
					<!-- name -->
					<span class="namein">
						<a href="?page=profile&user=username" id="name-<?php echo $post['ID_post'] ?>"><?php echo $post['username']; ?></a>
					</span>	
					<span id="space">_</span>
					<!-- time -->
					<span class="timein">
						<span id="time-<?php echo $post[$i]['ID_post'] ?>"><?php echo time() - $post['time'] ?></span>
					</span>	
					<!-- total like -->
					<br/>
					<span class ="likecountin">
						<img class="markin" src="theme/like-mark.png">
						<div id="likein"><?php echo $post['total_like'] ?></div>
					</span>	
					<!-- ncomment -->
					<span class="ncommentin">
						<img class="markin" src="theme/comment-mark.png">
						<span id="ncomment-<?php echo $post['ID_post'] ?>"><?php echo $post['jml_komentar'] ?></span>					
					</span>	
					<button id="but_likein" onclick="redrawLikedElement(this)" class="but_likein">Like</button>
					<button id="but_dislikein" onclick="redrawDislikedElement(this)" class="but_dislikein">Dislike</button>
				</div>
				
				<br/><div id="line" class="line"></div>					
				
				<?php $i=0; while($i< $ncomment) { ?>
				<div class="commentwrapper"id="commentwrapper-<?php echo $comment[$i]['id'] ?>">
					<img id="avatar-<?php echo $comment[$i]['id'] ?>" class="avatar-comment" src="<?php echo $comment[$i]['avatar'] ?>" />
					<div class="comment-content" id="cc-<?php echo $comment[$i]['id'] ?>">
						<a href="?page=profile&user=<?php echo $comment[$i]['username'] ?>" class="commentator" id="user-<?php echo $comment[$i]['id'] ?>"><?php echo $comment[$i]['username']; ?></a>
						<span class="space" id="space-<?php echo $comment[$i]['id'] ?>">_</span>
						<span class="time" id="time-<?php echo $comment[$i]['id'] ?>"><?php echo time() - $comment[$i]['waktu'] ?></span>
						<?php if($_SESSION['user'] == $comment[$i]['username']) { ?>
						<button id="delete-<?php echo $comment[$i]['id'] ?>" class="delete-comment" onclick="hapusKomen(<?php echo $comment[$i]['id'] ?>)"></button>
						<?php } ?>
						<div class="comment" id="comment-<?php echo $comment[$i]['id'] ?>"><?php echo $comment[$i]['isi'] ?></div>
					</div>
				</div>
				<br/>
				<?php $i++; } ?>
				
				
				<?php if(isset($_SESSION['user'])) { ?>
				
				<textarea id="boxcomment"></textarea>
				<button id="submitcomment" onclick="tambahKomen(<?php echo $_GET['id'] ?>)">Submit
				</button>
				<br/><br/>
				<?php } ?>
				<br>
			</div>

			<div class="paginasiin">
				<ul>
					<li> Page: </li>
					<?php 
						$i = 1;
						while($i<=$npage) {
							echo "<li><span id='space'>_</span><a href='?page=content&p=" . ($i) ."&id=". $_GET['id'] ."'> ". ($i) ." </a></li>";
							$i++;
						}
					?>
				</ul>
			</div>

		</div>
	</div>
</body>
</html>